package com.yupi.springbootinit.controller;

import com.yupi.springbootinit.common.BaseResponse;
import com.yupi.springbootinit.common.ResultUtils;
import com.yupi.springbootinit.model.entity.QaInspectionAppearance;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yupi.springbootinit.common.DeleteRequest;
import com.yupi.springbootinit.model.dto.qa.QaInspectionAppearanceAddRequest;
import com.yupi.springbootinit.model.dto.qa.QaInspectionAppearanceQueryRequest;
import com.yupi.springbootinit.model.dto.qa.QaInspectionAppearanceUpdateRequest;
import com.yupi.springbootinit.service.QaInspectionAppearanceService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


import java.util.List;/**
 * 检验报告外观接口
 *
 * @author zhang
 * @date 2024/02/25
 */
@RestController
@RequestMapping("/qa/inspection-appearance")
public class QaInspectionAppearanceController {

    @Resource
    private QaInspectionAppearanceService qaInspectionAppearanceService;

    // region 增删改查

    /**
     * 创建
     *
     * @param qaInspectionAppearanceAddRequest
     * @return
     */
    @PostMapping("/add")
    public BaseResponse<Long> addQaInspectionAppearance(@RequestBody QaInspectionAppearanceAddRequest qaInspectionAppearanceAddRequest) {
        long result = qaInspectionAppearanceService.addQaInspectionAppearance(qaInspectionAppearanceAddRequest);
        return ResultUtils.success(result);
    }

    /**
     * 删除
     *
     * @param deleteRequest
     * @return
     */
    @PostMapping("/delete")
    public BaseResponse<Boolean> deleteQaInspectionAppearance(@RequestBody DeleteRequest deleteRequest) {
        boolean result = qaInspectionAppearanceService.deleteQaInspectionAppearance(deleteRequest);
        return ResultUtils.success(result);
    }

    /**
     * 更新
     *
     * @param qaInspectionAppearanceUpdateRequest
     * @return
     */
    @PostMapping("/update")
    public BaseResponse<Boolean> updateQaInspectionAppearance(@RequestBody QaInspectionAppearanceUpdateRequest qaInspectionAppearanceUpdateRequest) {
        boolean result = qaInspectionAppearanceService.updateQaInspectionAppearance(qaInspectionAppearanceUpdateRequest);
        return ResultUtils.success(result);
    }

    /**
     * 根据 id 获取
     *
     * @param id
     * @return
     */
    @GetMapping("/get")
    public BaseResponse<QaInspectionAppearance> getQaInspectionAppearanceById(long id) {
        QaInspectionAppearance qaInspectionAppearance = qaInspectionAppearanceService.getQaInspectionAppearanceById(id);
        return ResultUtils.success(qaInspectionAppearance);
    }

    /**
     * 获取列表
     *
     * @param qaInspectionAppearanceQueryRequest
     * @return
     */
    @GetMapping("/list")
    public BaseResponse<List<QaInspectionAppearance>> listQaInspectionAppearance(QaInspectionAppearanceQueryRequest qaInspectionAppearanceQueryRequest) {
        List<QaInspectionAppearance> list = qaInspectionAppearanceService.listQaInspectionAppearance(qaInspectionAppearanceQueryRequest);
        return ResultUtils.success(list);
    }

    /**
     * 分页获取列表
     *
     * @param qaInspectionAppearanceQueryRequest
     * @return
     */
    @GetMapping("/list/page")
    public BaseResponse<Page<QaInspectionAppearance>> listQaInspectionAppearanceByPage(QaInspectionAppearanceQueryRequest qaInspectionAppearanceQueryRequest) {
        Page<QaInspectionAppearance> page = qaInspectionAppearanceService.listQaInspectionAppearanceByPage(qaInspectionAppearanceQueryRequest);
        return ResultUtils.success(page);
    }

    // endregion
}